<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>添加门店 - 766 SMART HOME</title>
<meta name="author" content="BIZ Team" />
<meta name="copyright" content="BIZ" />
<link href="${base}/resources/admin/css/common.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="${base}/resources/admin/js/jquery.js"></script>
<script type="text/javascript" src="${base}/resources/admin/js/jquery.tools.js"></script>
<script type="text/javascript" src="${base}/resources/admin/js/jquery.validate.js"></script>
<script type="text/javascript" src="${base}/resources/admin/editor/kindeditor.js"></script>
<script type="text/javascript" src="${base}/resources/admin/js/common.js"></script>
<script type="text/javascript" src="${base}/resources/admin/js/input.js"></script>
<style type="text/css">
	#ranges{height:100px;width:1200px}
	#mapContainer{height:600px;width:100%}
</style>
<script type="text/javascript">
$().ready(function() {
	[@flash_message /]
	var $inputForm = $("#inputForm");
	$("[name=provinceId]").change(function(){
		var provinceId = $(this).val();
		$.ajax({
		    url:"${base}/admin/shops/getChildrenByParentId.jhtml",    //请求的url地址
		    dataType:"json",   //返回格式为json
		    data:{"provinceId":provinceId},    //参数值
		    type:"GET",   //请求方式
		    success:function(req){
		        //请求成功时处理
		        $("[name=cityId]").empty();
		       $("[name=cityId]").append("<option value=''>请选择</option>");
		        for(var i=0;i<req.length;i++){
		        	$("[name=cityId]").append("<option value='"+req[i].id+"'>"+req[i].name+"</option>");
		        }
		    },
		    error:function(){
		        //请求出错处理
		    }
		});
	});
	$("[name=cityId]").change(function(){
		var provinceId = $(this).val();
		$.ajax({
		    url:"${base}/admin/shops/getChildrenByParentId.jhtml",    //请求的url地址
		    dataType:"json",   //返回格式为json
		    data:{"provinceId":provinceId},    //参数值
		    type:"GET",   //请求方式
		    success:function(req){
		        //请求成功时处理
		        $("[name=areaId]").empty();
		        $("[name=areaId]").append("<option value=''>请选择</option>");
		        for(var i=0;i<req.length;i++){
		        	$("[name=areaId]").append("<option value='"+req[i].id+"'>"+req[i].name+"</option>");
		        }
		    },
		    error:function(){
		        //请求出错处理
		    }
		});
	});
	if(${shops.shopsNature}==0){
			$("#serviceArea").attr("class","hidden");
	}
});

</script>
</head>
<body>
	<div class="path">
		<a href="${base}/admin/common/index.jhtml">${message("admin.path.index")}</a> &raquo;查看门店
	</div>
	<form id="inputForm" action="update.jhtml" method="post">
		<ul id="tab" class="tab">
			<li>
				<input type="button" value="门店基本信息" />
			</li>
		</ul>
		<table class="input tabContent">
			<tr>
				<th>
					<span class="requiredField"></span>门店名称:
				</th>
				<td>
					<input type="text" name="shopsName" class="text" maxlength="200" value="${shops.shopsName}" readonly="readonly"/>
					<input type="hidden" name="id" class="text" maxlength="200" value="${shops.id}"/>
				</td>
			</tr>
			<tr>
				<th>
					<span class="requiredField"></span>门店地址:
				</th>
				<td>
					<input type="text" name="address" class="text" maxlength="200" value="${shops.address}" readonly="readonly"/>
				</td>
			</tr>
			<tr>
				<th>
					<span class="requiredField"></span>联系人:
				</th>
				<td>
					<input type="text" name="contactP" class="text" value="${shops.contactP}" readonly="readonly" />
				</td>
			</tr>
			<tr>
				<th>
					<span class="requiredField"></span>联系人电话:
				</th>
				<td>
					<input type="text" name="contactT" class="text" value="${shops.contactT}" readonly="readonly"/>
				</td>
			</tr>
			<tr id="storeTypeTemp">
				<th>
					<span class="requiredField"></span>门店类型:
				</th>
				<td>
					 <select class="option" name="storeType"  disabled="disabled">
					 [#list shopsTypeList as shopsType]
					 	<option value="${shopsType.id}">${shopsType.title}</option>
					 [/#list]
					</select>
				</td>
			</tr>
			<tr>
				<th>
					<span class="requiredField"></span>门店性质:
				</th>
				<td>
					<input type="checkbox" disabled="disabled" [#if shops.shopsNature==0 || shops.shopsNature==2]checked="checked"[/#if] name="orderShops" value="0"/><span>下单门店</span><input type="checkbox" disabled="disabled" [#if shops.shopsNature==1 || shops.shopsNature==2]checked="checked"[/#if] name="serviceShops" value="1"/><span>服务门店</span>
					<input class="hidden" name="tempShopsNature" id="tempValue" value="1"/>
				</td>
			</tr>
			<tr>
				<th>
					<span class="requiredField"></span>纳税人类别:
				</th>
				<td>
					<select class="option" name="taxpayerType" disabled="disabled">
					 [#list taxpayerType as taxpayerType]
					 	<option value="${taxpayerType.id}">${taxpayerType.title}</option>
					 [/#list]
					</select>
				</td>
			</tr>
			<tr>
				<th>
					<span class="requiredField"></span>门店规模:
				</th>
				<td>
					 <select class="option" name="storeScale" disabled="disabled">
					 [#list storeScale as storeScale]
					 	<option value="${storeScale.id}">${storeScale.title}</option>
					 [/#list]
					 </select>
				</td>
			</tr>
			<tr>
				<th>
					<span class="requiredField"></span>门店区域:
				</th>
				<td>
				 <select class="option" name="provinceId" disabled="disabled" info="${shops.provinceId}">
				 	<option value="">请选择</option>
					[#list parentList as li]
						<option value="${li.id}">${li.name}</option>
				 	[/#list]
				 </select>
				 <select class="option" name="cityId" disabled="disabled">
				 	<option value="">请选择</option>
				 	[#list getChildrenListOne as liOne]
				 		<option value="${liOne.id}">${liOne.name}</option>
				 	[/#list]
				 </select>
				 <select class="option" name="areaId" disabled="disabled">
				 	<option value="">请选择</option>
				 	[#list getChildrenListTwo as liTwo]
				 		<option value="${liTwo.id}">${liTwo.name}</option>
				 	[/#list]
				 </select>
				</td>
			</tr>
			<tr id="shopsLV">
				<th>
					<span class="requiredField"></span>门店等级:
				</th>
				<td>
					 <select class="option" name="shopsLevel" info="${shops.shopsLevel}" disabled="disabled">
					 <option value="">--请选择--</option>
					 [#list shopsLV as shopsLV]
					 	<option value="${shopsLV.id}">${shopsLV.title}</option>
					 [/#list]
					</select>
				</td>
			</tr>
			[#if shops.shopsLevel==173]
			<tr id="shopsLevelChirld">
				<th>
					<span class="requiredField"></span>请选择A级门店:
				</th>
				<td>
					 <select class="option" name="shopsLevelA" info="${shops.shopsA}" disabled="disabled">
					 <option value="">--请选择--</option>
					 [#list shopsLevelA as shopsLevelA]
					 	<option value="${shopsLevelA.id}">${shopsLevelA.shopsName}</option>
					 [/#list]
					</select>
				</td>
			</tr>
			[/#if]
			<tr id="serviceArea">
				<th>
					<span class="requiredField"></span>服务区域:
				</th>
				<td id="addArea">
					[#list serviceAreaList as serviceAreaList]
						<span><input class='hidden' name='tempId' value='${serviceAreaList.areaId}'/><a href='javascript:;' name='tempName'>[${serviceAreaList.areaName}]</a></span>
					[/#list]
				</td>
			</tr>
			[#if shops.storeType!=43]
			<tr id="sad">
				<th>
					<span class="requiredField"></span>门店具体地址:
				</th>
				<td>
				 	<input type="text" class="text" id="addressText" name="gpsAddress" value="${shops.gpsAddress}" readonly="readonly"/>
				</td>
			</tr>
			[/#if]
			<tr id="position">
				[#if shops.storeType!=43]
				<th>
					<span class="requiredField"></span>门店位置:
				</th>
				[/#if]
				<td>
					[#if shops.storeType==43]
						<div id="mapContainer" class="hidden"></div>
					[#else]
						<div id="mapContainer"></div>
					[/#if]
					<input type="hidden" name="gpsX" id="coordinateX"class="text coordinateX" value="${shops.gpsX}"/>
					<input type="hidden" name="gpsY" id="coordinateY" class="text coordinateY" value="${shops.gpsY}"/>
				</td>
			 </tr>
			<tr>
				<th>
					<span class="requiredField"></span>经营范围:
				</th>
				<td>
					<textarea name="ranges" id="ranges" readonly="readonly">${shops.ranges}</textarea>
				</td>
			 </tr>
		</table>
		<table class="input">
			<tr>
				<th>
					&nbsp;
				</th>
				<td>
					<input type="button" class="button" value="${message("admin.common.back")}" onclick="location.href='list.jhtml'" />
				</td>
			</tr>
		</table>
	</form>
</body>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=494PEuZs8md8xKnsIvrYYmvq"></script>
<script type="text/javascript" src="${base}/resources/admin/js/locationMap.js"></script>
<script type="text/javascript">
$(function() {
	var coordinateX = $("#coordinateX").val();
	var coordinateY = $("#coordinateY").val();
	var point = new BMap.Point(coordinateY,coordinateX);
	map.centerAndZoom(point,11);
	var marker =new BMap.Marker(point)
	map.addOverlay(marker);
	var tempShopsName = $("[name=shopsName]").val();
	
	if(tempShopsName=='总部售后'){
		//隐藏掉地图
		$("#sad").attr("class","hidden");
		$("#position").attr("class","hidden");
		$("[name=gpsX]").remove();
		$("[name=gpsY]").remove();
		//隐藏掉门店类型
		$("#storeTypeTemp").attr("class","hidden");
		$("#serviceArea").attr("class","hidden");
		//门店性质复选框设置
		$("[name=orderShops]").attr("disabled","disabled");
		$("[name=orderShops]").removeAttr("checked");
		$("[name=serviceShops]").attr({disabled:'disabled',checked:'checked'});
	}
	$("[name=shopsLevel] option[value=${shops.shopsLevel}]").attr("selected", "selected");
	$("[name=shopsLevelA] option[value=${shops.shopsA}]").attr("selected", "selected");
	$("[name=storeType] option[value=${shops.storeType}]").attr("selected", "selected");
	$("[name=taxpayerType] option[value=${shops.taxpayerType}]").attr("selected", "selected");
	$("[name=storeScale] option[value=${shops.storeScale}]").attr("selected", "selected");
	$("[name=provinceId] option[value=${shops.provinceId}]").attr("selected", "selected");
	$("[name=cityId] option[value=${shops.cityId}]").attr("selected", "selected");
	$("[name=areaId] option[value=${shops.areaId}]").attr("selected", "selected");
});
</script>
</html>